const { ccclass, property } = cc._decorator;

@ccclass
export default class Start extends cc.Component {

    @property(cc.Button)
    startGameBtn: cc.Button = null;

    @property(cc.Button)
    goOnBtn: cc.Button = null;

    @property(cc.Button)
    settingBtn: cc.Button = null;

    @property(cc.Button)
    shopBtn: cc.Button = null;

    @property(cc.AudioClip)
    backgroundMusic: cc.AudioClip = null;

    @property(cc.AudioClip)
    clickMusic: cc.AudioClip = null;

    onLoad() {

        //播放背景音乐
        var bgmId = cc.audioEngine.play(this.backgroundMusic, true, 0.5);
        cc.director.preloadScene("Game");
        this.startGameBtn.node.on(cc.Node.EventType.TOUCH_END, event => {
            cc.audioEngine.play(this.clickMusic, false, 0.5);
            cc.director.loadScene("Game",()=>{
                cc.audioEngine.stop(bgmId)
            })
        })
    }
}
